﻿
#nullable disable
using DataWorks_IDAL;

namespace DataWorks_BLL
{
    public  class BLL_Base<T> where T : class, new()
    {

        public IDAL_Base<T> CurrentDal { get; set; }
        //public abstract void SetCurrentDal();
        //public BLL_Base()
        //{
        //    SetCurrentDal();//子类一定要实现抽象方法，一旦创建抽象子类的实例时，就会调用此方法
        //}

        public IQueryable<T> LoadEntities
         (System.Linq.Expressions.Expression<Func<T, bool>> whereLambda)
        {
            return CurrentDal.LoadEntities(whereLambda);
        }

        public bool DeleteEntity(T entity)
        {
            CurrentDal.DeleteEntity(entity);
            return CurrentDal.SaveChanges();
        }
        public bool EditEntity(T entity)
        {
            CurrentDal.EditEntity(entity);
            return CurrentDal.SaveChanges();
        }
        public bool AddEntity(T entity)
        {
            CurrentDal.AddEntity(entity);

            return CurrentDal.SaveChanges();
        }
       
    }
}